<template>
  <div>
    <el-dialog
      title="选择采购验收单"
      :visible.sync="dialogTableVisible"
      :close-on-click-modal="false"
      :before-close="close"
      width="1000px">
      <el-form :model="selectForm" ref="queryForm" :inline="true">
        <el-form-item label="计划单号" label-width="90px">
          <el-input v-model="selectForm.planCode" placeholder="请输入采购计划单号" clearable size="small"
                    @keyup.enter.native="getList"/>
        </el-form-item>
        <!-- <el-form-item label="计划标题">
          <el-input v-model="selectForm.title" placeholder="请输入采购计划标题" clearable size="small"
                    @keyup.enter.native="getList"/>
        </el-form-item> -->
        <el-form-item label="申请日期" label-width="90px">
          <el-date-picker @keyup.enter.native="getList" v-model="date" size="small" value-format="yyyy-MM-dd"
                          type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"
                          @change="dateSelect"></el-date-picker>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" size="mini" @click="getList">搜索</el-button>
          <el-button type="primary"  size="mini" @click="sumbit">确 定</el-button>
        </el-form-item>
      </el-form>
      <el-table v-loading="loading" :data="list.rows" border highlight-current-row @current-change="currentChange">
        <el-table-column align="center" type="index" label="序号" width="55"/>
        <el-table-column align="center" label="采购计划单号" property="planCode" width="150" />
        <el-table-column align="center" label="采购计划标题" property="title"/>
        <el-table-column align="center" label="采购计划类型" property="purchasePlanType">
          <template slot-scope="scope" style="text-align: center">
            <template v-if="scope.row.purchasePlanType==1">临时</template>
            <template v-if="scope.row.purchasePlanType==2">月度</template>
            <template v-if="scope.row.purchasePlanType==3">年度</template>
          </template>
        </el-table-column>
        <el-table-column align="center" label="申请人" property="applyUserName"/>
        <el-table-column align="center" label="申请日期" property="applyTime"/>
<!--        <el-table-column label="验收日期" align="center" width="180">-->
<!--          <template slot-scope="scope">-->
<!--            {{ parseTime(scope.row.acceptDate) }}-->
<!--          </template>-->
<!--        </el-table-column>-->
<!--        <el-table-column label="申请状态" property="verifyStatus" :show-overflow-tooltip="true"/>-->
        <el-table-column label="审核状态" align="center" width="120">
          <template slot-scope="scope">
            <span v-show="scope.row.verifyStatus==0">审核中</span>
            <span v-show="scope.row.verifyStatus==1">审核结束</span>
          </template>
        </el-table-column>
      </el-table>
      <pagination
        :total="list.total?list.total:0"
        :page.sync="selectForm.pageNum"
        :limit.sync="selectForm.pageSize"
        @pagination="getList"
      />
      <span slot="footer" class="dialog-footer">

      </span>
    </el-dialog>
  </div>
</template>

<script>
  import { deviceAccept,procurePlan } from '@/api/purchase/index'

  export default {
    data() {
      return {
        list:[],
        selectForm: {
          pageNum: 1,
          pageSize: 10,
          planCode: '',
          title: '',
          applyBeginTime: '',
          applyEndTime: ''
        },
        date:'',
        loading:false,
        dialogTableVisible:true,
        selectData:'',
      };
    },
    created() {
      this.getList()
    },
    methods: {
      close() {
        this.$emit('qzysdBack')
      },
      /** 查询列表 */
      async getList() {
        this.loading = true
        let res = await procurePlan(this.selectForm)
        this.list = res
        this.loading = false
      },
      dateSelect() {
        this.selectForm.applyBeginTime = this.date&&this.date[0]||null
        this.selectForm.applyEndTime = this.date&&this.date[1]||null
      },
      currentChange(val) {
        this.selectData=val;
      },
      sumbit(){
        this.$emit('qzysdBack',this.selectData)//将submitModel的值传给父组件
      },


    }
  };
</script>
<style >
</style>
